# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>

pkgname=moosefs
pkgver=3.0.117
pkgrel=1
pkgdesc='High performing and fault tolerant distributed file system'
url='https://moosefs.com/'
replaces=(mfs-chunkserver mfs-client mfs-master)
conflicts=(mfs-chunkserver mfs-client mfs-master)
arch=(loong64 x86_64)
license=(GPL2)
depends=(fuse3 libpcap python xfsprogs)
makedepends=(git)
source=("git+https://github.com/moosefs/moosefs#commit=79bca600d6ddfecfcb29af2fc6632b4e3d00f1a5" # tag: v3.0.117
        moosefs.tmpfiles
        moosefs.sysusers)
b2sums=('SKIP'
        '60c51df91a09e6680e10ffd0b3284a594ba585226f4acad7d389d6b39e98243d980155cb2ab83acf1a1b4ccf167bc682b7672121587e69280832127d472ede38'
        '1d725b36f8c5d7ca458cc64166ebf8d1c477c32c51c652e8f521b37eeed942ca2f3ca098de2c1a65d524257308fc8758071bd129624c2d82022f38bda3823a5e')

build() {
  cd $pkgname
  ./configure \
    --localstatedir=/var/lib \
    --mandir=/usr/share/man \
    --prefix=/usr \
    --sysconfdir=/etc \
    --with-default-group=mfs \
    --with-default-user=mfs \
    --with-systemdsystemunitdir=/usr/lib/systemd/system
  make
}

package() {
  make DESTDIR="$pkgdir" -C $pkgname install

  install -Dm644 "$pkgname.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf"
  install -Dm644 "$pkgname.sysusers" "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"

  # Move mount.moosefs from sbin to usr/bin. They end up in
  # /usr/bin just the same, but this silences a warning
  mv "$pkgdir/sbin/"* "$pkgdir/usr/bin/"
  mv "$pkgdir/usr/sbin/"* "$pkgdir/usr/bin/"
  rmdir "$pkgdir/sbin" "$pkgdir/usr/sbin"
}
